package uiobj
{
	import datas.GlobalDatas;
	
	import events.GlobalEvents;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Loader;
	import flash.display.LoaderInfo;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Matrix;
	import flash.net.URLLoader;
	import flash.net.URLRequest;

	public class ListThumb extends Sprite
	{
		private var _url:String;
		private var _thumb:String;
		
		public function get url():String
		{
			return _url;
		}
		
		public function get thumb():String
		{
			return _thumb;
		}
		
		public function ListThumb()
		{
			addEvent();
		}
		
		private function addEvent():void
		{
			addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
			addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
		}
		
		public function load($value:XML):void
		{
			_url = $value.url;
			_thumb = $value.thumb;
			var request:URLRequest = new URLRequest(_thumb);
			var loader:Loader = new Loader;
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
			loader.load(request);
			addChild(loader);
		}
		
		private function onComplete(e:Event):void
		{
			
		}
		
		private function msk():Bitmap
		{
			var bd:BitmapData = new BitmapData(GlobalDatas.THUMB_SIZE,GlobalDatas.THUMB_SIZE,false,0x000000);
			var bm:Bitmap = new Bitmap(bd);
			addChild(bm);
			return bm;
		}
		
		private function onMouseDown(e:MouseEvent):void
		{
			this.alpha = 0.5;
		}
		
		private function onMouseUp(e:MouseEvent):void
		{
			this.alpha = 1;
			GlobalDatas.currentPhoto = this;
			GlobalEvents.showSingle();
		}
		
		
	}
}
